package cn.team.service.impl;

import cn.team.entity.User;
import cn.team.mapper.UserMapper;
import cn.team.service.UserService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;
    @Resource
    PasswordEncoder passwordEncoder;
    @Override
    public int saveUser(String username, String password,String portraitName) {
        return userMapper.registerUser(username,passwordEncoder.encode(password),portraitName);
    }

    @Override
    public User getUser(String name) {
        return userMapper.getUser(name);
    }

    @Override
    public User getUserById(int id) {
        return userMapper.getUserById(id);
    }
}
